﻿using System;
using System.Collections.Generic;
using System.Text;

public class Snake
{
    private int x;
    private int y;
    private int dx;
    private int dy;
    private int height;
    private int width;

    private IList<int> xA;
    private IList<int> yA;

    private int speed;
    
    public int X
    {
        get { return x; }
        set { x = value; }
    }
    public int Y
    {
        get { return y; }
        set { y = value; }
    }
    public int Dx
    {
        get { return dx; }
        set { dx = value; }
    }
    public int Dy
    {
        get { return dy; }
        set { dy = value; }
    }


    public Snake()
    {
        speed = 3;

        height = 25;
        width = 25;

        xA = new List<int>();
        yA = new List<int>();
        xA.Add(100);
        yA.Add(100);

        x = 100;
        y = 100;
        dx = speed;
        dy = 0;
    }

    public void actuPos()
    {
        x = x + dx;
        y = y + dy;
    }

    public void goUp()
    {
        dx = 0;
        dy = -speed;
    }

    public void goDown()
    {
        dx = 0;
        dy = speed;
    }

    public void goRight()
    {
        dx = speed;
        dy = 0;
    }

    public void goLeft()
    {
        dx = -speed;
        dy = 0;
    }

    public void checkWall(int topWall, int bottomWall, int leftWall, int rightWall)
    {
        // if colision with the wall on the right
        if (x > rightWall && dx > 0)
            x = leftWall - width;
        // if colision with the wall on the left
        if ( (x + width) < leftWall && dx < 0)
            x = rightWall;
        // if colision with the wall on the top
        if ( (y + height) < topWall && dy < 0) 
            y = bottomWall;
        // if colision with the wall on the bottom
        if (y > bottomWall && dy > 0)
            y = topWall - (height);
    }
        
}
